///********************************************************************
///* Copyright © 2012 fishr (fishr.flash@gmail.com)  
///********************************************************************


package su.fishr.social_network.OK.uploadV2.utils 
{
	import api.com.adobe.crypto.MD5;
	
	   

	/** 
	 * @private 
	 * 
	 * Создает хеш для подписи запросов.
	 * 
	 * @playerversion          Flash 10
	 * @langversion            3.0
	 * @author                 fishr
	 * @created                30.05.2012 5:51
	 * @since                  30.05.2012 5:51
	 */
	public function CalculateHash( data:Object, secret_key:String ):String
	{
		var keys:Array = new Array();
		var sig:String = "";
		
		data["format"] = "JSON";
		
		for ( var name:String in data )
		{
			keys.push( name );
		}
		
		keys.sort();
		
		for ( var i:int = 0; i < keys.length; i++ )
		{
			sig += keys[ i ] + "=" + data[ keys[i] ];
		}
		
		sig += secret_key;

		return MD5.hash( sig ).toLowerCase();
	}

}